import { EntityModel } from '@midwayjs/orm';
import {
  Column,
  PrimaryGeneratedColumn,
  // ManyToOne,
  // OneToMany,
  // ManyToMany,
  // JoinTable,
} from 'typeorm';
import dayjs from 'dayjs';
// import { FriendEntity } from './friend';

@EntityModel({
  name: 'user',
})
export class UserEntity {
  @PrimaryGeneratedColumn({
    type: 'bigint',
    comment: '用户名',
  })
  id: number;

  @Column({
    type: 'varchar',
    length: 50,
    nullable: false, // 不能为null
    comment: '用户名',
  })
  username: string;

  @Column({
    type: 'varchar',
    length: 20,
    nullable: false, // 不能为null
    comment: '账户',
  })
  account: string;

  @Column({
    type: 'varchar',
    length: 20,
    nullable: false, // 不能为null
    comment: '邮箱',
  })
  email: string;

  @Column({
    type: 'varchar',
    length: 20,
    nullable: false, // 不能为null
    comment: '密码',
  })
  password: string;

  @Column({
    type: 'varchar',
    length: 10,
    nullable: false, // 不能为null
    comment: '性别',
  })
  sex: string;

  @Column({
    type: 'varchar',
    length: 20,
    nullable: false, // 不能为null
    comment: '生日',
  })
  birth: string;

  @Column({
    type: 'varchar', // 类型
    length: 20, // 长度
    nullable: false, // 不能为null
    default: '', // 默认值
    comment: '电话', // 描述
  })
  phone: string;

  @Column({
    type: 'varchar',
    length: 50,
    nullable: false, // 不能为null
    comment: '介绍描述',
  })
  desc: string;

  @Column({
    type: 'varchar',
    length: 100,
    nullable: false, // 不能为null
    default: '', // 默认值
    comment: '用户头像',
  })
  imgUrl: string;

  @Column({
    type: 'varchar',
    length: 20,
    nullable: false, // 不能为null
    default: dayjs().format('YYYY-MM-DD HH:mm:ss'), // 默认值
    comment: '注册时间',
  })
  createTime: string;

  @Column({
    type: 'varchar',
    length: 20,
    nullable: false, // 不能为null
    default: dayjs().format('YYYY-MM-DD HH:mm:ss'), // 默认值
    comment: '更新时间',
  })
  updateTime: string;
  status: number;

  // @OneToMany(type => FriendEntity, friend => friend.users)
  // friends: FriendEntity[];

  // @ManyToMany(type => UserEntity, friends => friends.users1)
  // friends: UserEntity[];

  // @JoinTable({
  //   name: 'question_categories', // 此关系的联结表的表名
  //   joinColumn: {
  //     name: 'userId',
  //     referencedColumnName: 'id',
  //   },
  //   inverseJoinColumn: {
  //     name: 'friendId',
  //     referencedColumnName: 'friendId',
  //   },
  // })
}
